/*
 * MsgConn.h
 *
 *  Created on: 2013-7-5
 *      Author: ziteng@mogujie.com
 */

#ifndef MSGCONN_H_
#define MSGCONN_H_

#include "imconn.h"

class CMsgConn : public CImConn
{
public:
	CMsgConn();
	virtual ~CMsgConn();
    uint32_t GetUserId() { return m_user_id; }
    void SetUserId(uint32_t user_id) { m_user_id = user_id; }
    uint32_t GetHandle() { return m_handle; }
    uint32_t GetClientType() { return m_client_type; }
    void SetOpen() { m_bOpen = true; }
    bool IsOpen() { return m_bOpen; }

	virtual void Close();

	virtual void OnConnect(net_handle_t handle);
	virtual void OnClose();
	virtual inline void OnTimer(uint64_t curr_tick);

	virtual void HandlePdu(CImPdu* pPdu);
private:
    
    // for webRTC
    void _HandleLogin(CImPdu* pPdu);
    void _HandleInitCallReq(CImPdu* pPdu);
    void _HandleCallNotifyRes(CImPdu* pPdu);
    void _HandleHungUpReq(CImPdu* pPdu);
    void _HandleHungUpNotifyRes(CImPdu* pPdu);
    void _HandleOnlineUserReq(CImPdu* pPdu);
    
private:
    uint32_t        m_user_id;
    bool			m_bOpen;	// only DB validate passed will be set to true;
    
    uint32_t        m_client_type;        //客户端登录方式
};

void init_msg_conn();

#endif /* MSGCONN_H_ */
